<template>
  <div style="height: 660px;background-color: #194398">
    <div style="padding-top: 10px;padding-bottom: 10px">
      <van-uploader :after-read="upload">
        <van-button>上传</van-button>
      </van-uploader>&nbsp;
      <van-button @click="download">导出</van-button>&nbsp;
      <van-button @click="showPopup">增加</van-button>&nbsp;<van-button>删除</van-button>
    </div>
    <div>
<!--      <van-cell is-link @click="">展示弹出层</van-cell>-->
      <van-popup position="top" v-model:show="show">
        <van-field label="组织名称" v-model="name" />
        <van-button @click="add">提交</van-button>
      </van-popup>
<!--      <van-popup v-model:show="flag">-->
<!--        asdadasda-->
<!--      </van-popup>-->
    </div>
    <el-tree style="height: 615px ;background-color: slategray" :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
  </div>


</template>

<script>
import myaxios from "../../../https/myaxios";
import fileDownload from "js-file-download";
// import axios from 'axios';

export default {
  name:'group_manage',
  props:["data","id"],
  data() {
    return {
      defaultProps: {
        children: 'children',
        label: 'label',
      },
      show:false,
      name:'',
    }
  },
  methods: {
    showPopup(){
      this.show = true;
    },
    add(){
      let data = new FormData()
      data.append("pid",this.id)
      alert(this.id)
      data.append("name",this.name)
      myaxios('addcompany','post',data).then(res=>{
        console.log(res.msg)

      })
    },
    handleNodeClick(data) {
      this.$emit("send-id",data["id"])
      // console.log(data["id"])
    },
    upload(file){
      let data = new FormData()
      data.append("file",file.file)
      console.log(file)
      myaxios("upload", "post", data).then(res=>{
        console.log(res.msg)
      })
    },
    download(){
      myaxios("download", "post").then(res=>{
        fileDownload(res.data,'file.xls');
      })
      // axios({url:"http://127.0.0.1:5000/download",method:"get",'responseType':"arraybuffer",}).then(res=>{
      //   fileDownload(res.data,'file.xls');
      // })
    },
  },
}
</script>
<style scoped>
/deep/.el-tree-node__content{
  height: 40px;
}

/deep/.el-tree{
  --el-tree-text-color:#194398;
}
</style>